package org.zhangyp.basicauth.bean;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户Bean
 *
 * @author ypzhang
 * @since 2025/5/28
 */
@Data
public class UserBean {
    private String userId;
    private String userName;
    private String userPass;
    private List<RoleBean> userRoles = new ArrayList<>();
    private List<ResourceBean> resourceBeans = new ArrayList<>();

    public UserBean() {

    }

    public UserBean(String userId, String userName, String userPass) {
        this.userId = userId;
        this.userName = userName;
        this.userPass = userPass;
    }

    public boolean havaPermission(String resource) {
        return this.resourceBeans.stream().anyMatch(resourceBean -> resourceBean.getResourceName().equals(resource));
    }
}
